package com.vidmt.api.modules.sys.auth;

import com.vidmt.api.modules.sys.auth.PwdStrategy.ReversePwdStrategy;

public abstract class DefaultReversPwdStrategy extends DefaultPwdStrategy implements ReversePwdStrategy {
	@Override
	final public boolean valid(String plainpwd, String savedPassword) {
		return  plainpwd.equals(decryptPassword(savedPassword));
	}

	@Override
	final public String decryptPassword(String savedPwd) {
		String[] arr = savedPwd.split("#");
		return getPlainPwd(defmtKey(arr[1]), arr[2]);
	}

	abstract protected String getPlainPwd(String rawkey, String ecryptedpwd);
}
